package NG::Sys::Cached::Reference::Constants;
use strict;
use warnings;

use NG::Sys::Cached::DBReference;
our @ISA = qw(NG::Sys::Cached::DBReference);

our $AUTOLOAD;
sub AUTOLOAD {
	my $self = shift;
	(my $key = $AUTOLOAD) =~ s/.*://;

	my $row = $self->get_by_index($key) || die "bad constant name '$key'";
	my $ret = $row->{$self->{vkey}};
	unless(defined $ret){
		die "unedfined constant name '$key'";
	}
	if($self->{compile}){
		no strict 'refs';
		*{$AUTOLOAD} = eval "sub {
			return $ret;
		}";
		goto &{$AUTOLOAD};
	}else{
		return $ret;
	}
}
sub DESTROY{}


1;
